package com.example.demo.controller;

import com.example.demo.bean.Records;
import com.example.demo.service.MessageCostService;
import com.example.demo.service.StatusChangeService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/api")
@RestController
public class MessageCostController {
    @Resource
    MessageCostService messageCostService;
    @Resource
    StatusChangeService statusChangeService;
    @GetMapping("/cost")
    public ResponseEntity<List<Map<String,Object>>> messageCost(@RequestParam String recordId){
        int record_id = Integer.parseInt(recordId);
        return ResponseEntity.ok(messageCostService.get_cost_message(record_id));
//          double cost = messageCostService.findCost(Integer.parseInt(message_id));
//          double empty_distance = messageCostService.getEmpty_distance(Integer.parseInt(message_id));
//          double load_waste = messageCostService.getLoad_waste(Integer.parseInt(message_id));
//          double car_utilization = messageCostService.car_utilization(Integer.parseInt(message_id));
//          statusChangeService.carPosition_change(Integer.parseInt(message_id));
//          Map<String,Object> costs = new HashMap<>();
//          costs.put("cost",cost);
//          costs.put("emptyDistance",empty_distance);
//          costs.put("loadWaste",load_waste);
//          costs.put("carUtilization",car_utilization);
//          return ResponseEntity.ok(costs);
    }

    @GetMapping("/cost_list")
    public ResponseEntity<Map<String,Object>> getCostList(@RequestParam String page){
        return ResponseEntity.ok(messageCostService.get_cost_list(Integer.parseInt(page)));
    }
}
